/*
 * @Author: JiraiyaChen 979526234@qq.com
 * @Date: 2023-06-12 09:21:12
 * @LastEditors: JiraiyaChen 979526234@qq.com
 * @LastEditTime: 2024-03-19 09:49:39
 * @FilePath: \供应商系统\src\hooks\use-dialog.ts
 * @Description: 弹框通用hook
 */
import { ref } from 'vue'
export const useDialog = (refDom) => {
  let type = ref<string>('')
  // 新增/编辑 弹框
  let hookVisible = ref<boolean>(false)
  const onCloseDialog = (str) => {
    hookVisible.value = false
    if (str == 'refresh-table') refDom?.value?.initTable()
    if (str == 'refresh-tree') refDom()
  }
  // 编辑
  let dialogInfo = ref<any>({})
  const onOpenDialog = (row) => {
    dialogInfo.value = cloneDeep(row)
    hookVisible.value = true
  }
  return {
    type,
    hookVisible,
    dialogInfo,
    onOpenDialog,
    onCloseDialog
  }
}
